/**
 * Created by ANJ019 on 2017/5/10.
 */
/*@chat*/
/*首页轮播图开始*/
$(function() {

    var piclist = $("li.pic");

    var number = $(".numberList > li");

    var currenpic = piclist.eq(0);

    var i = 0;

    var timer = setInterval(auto, 3000);

    function auto() {
        i++;
        if (i > piclist.length - 1) {
            i = 0;

        };

        currenpic.fadeOut(1500);
        number.eq(currenpic.index()).removeClass("bannerAc");
        currenpic = piclist.eq(i).fadeIn(1500);
        number.eq(i).addClass("bannerAc");
    };
    $("#index-banner").on("mouseover", function () {
        clearInterval(timer);
    });
    $("#index-banner").on("mouseout", function () {
        timer = setInterval(auto, 3000);
    });

    number.on("click",function(){
       i= $(this).index();
        $(this).addClass('bannerAc').siblings().removeClass('bannerAc');
        currenpic=piclist.eq(i);
        currenpic.fadeIn(500).siblings().fadeOut(500);

    });


    /*首页轮播图结束*/

    /*首页首页新闻选项卡切换开始*/
    (function(){

        var ONews=$("#index-corporate-news");
        var Btns=ONews.find(".optionBtnWrap a");//找到所有的按钮
        var showsPanel=ONews.find(".newListContent ul");

        var OLog=Btns.eq(0);


        //------------------------------------鼠标滑入滑出
            Btns.hover(function(){
                clearInterval(ONews.time);
                Btns.removeClass("btnActive");
                $(this).addClass("btnActive");
            },function(){
                ONews.time=setInterval(function(){
                    Btns.removeClass("btnActive");
                    OLog.addClass("btnActive");
                },50);

            });
        //----------------------------------------------鼠标点击
        Btns.on("click",function(){
            Btns.removeClass("btnActive");
            OLog=$(this).addClass("btnActive");
            var _index=Btns.index(OLog);

            showsPanel.fadeOut("fast");

            showsPanel.eq(_index).fadeIn("slow");
        });

    })()

    /*首页首页新闻选项卡切换结束*/

    /*视频弹窗开始*/
    var OvideoWindow=null;
    var closeBtn=null;
    var mask=null;
    var startWindow= $('#index-company-introduction .indexIntroductionVideoMask');
    var video=null;

    startWindow.on("click",function(){

        init();
        action();
        //createVideoWindow();
        //center(OvideoWindow);
    });
    function init(){
        OvideoWindow=$("#videoWindow");
        closeBtn=$("#videoWindow").find(" .closeBtn");
        video=$("#videoWindow").find("video");
        mask=$('.mask');

    };
    function action(){
        mask.show();
        OvideoWindow.show();
        center(OvideoWindow);
        video.trigger('play');
        closeBtn.on("click",function(){
           video.trigger('pause');
            mask.hide();
            OvideoWindow.hide();
        });
        $(window).resize(function () {          //当浏览器大小变化时
            center(OvideoWindow);
        });

    };

    function center(odiv){
        var centerLeft=($(window).width()-odiv.width())/2;
        var centerTop=($(window).height()-odiv.height())/2;
        odiv.css({"left":centerLeft,"top":centerTop});
    };
    /*视频弹窗结束*/

   });














































































